import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/viewmodel/medecine/treatment_sheet_detail_view_model.dart';
class TreatmentSheetDetailPage extends BaseStatefulMvvmWidget{
  dynamic id;

  TreatmentSheetDetailPage(this.id);

  @override
  State<StatefulWidget> createState() => _TreatmentSheetDetailState();

}

class _TreatmentSheetDetailState extends BaseMvvmListState<TreatmentSheetDetailViewModel,TreatmentSheetDetailPage>{
  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      backgroundColor: Colours.bg_color,
      appBar: AppBar(
        title: Text("治疗单详情"),
      ),
      body: loadingContentWidget,
    );
  }

  @override
  Widget createItemWidget(int index) {
    var item = viewModel.listItems[index];
    return Stack(
      alignment: Alignment.center,
      children: [
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisSize: MainAxisSize.min,
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: [
                CommonText('${item.customerName??""}',textSize: 17,fontWeight: FontWeight.bold),
                SizedBox(width: 10,),
                CommonText('${item.bedNo??""}',textSize: 15),
                SizedBox().setWeight(1),
                // CommonText('处方号：CF6165522',fontWeight: FontWeight.bold)
              ],
            ),

            CommonText('开单日期：${item.prescriptionDate??""}'),
            CommonText('治疗单号：${item.prescriptionNo??""}'),
            Text.rich(TextSpan(
                text: '执行状态：',style: TextStyle(color: Colors.black,fontSize: 16),
                children: [
                  TextSpan(
                      text: '${item.statusName??""}',
                      style: TextStyle(fontSize: 17,color: Colors.blue,fontWeight: FontWeight.bold)
                  )
                ]
            )),
            CommonText('执行人：${item.executorName??""}'),
            CommonText('执行时间：${item.executorTime??""}'),
          ].insertWidget(SizedBox(height: 10,)),
        ),
        Column(
          children: [
            CommonText('项目名称'),
            SizedBox(height: 15,),
            CommonText('小换药',fontWeight: FontWeight.bold,textColor: Colors.blue,textSize: 18),
          ],
        ).setLocation(right: 40,top: 10)
      ],
    ).addToContainer(
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: 6.borderRadius
        ),
        padding: EdgeInsets.symmetric(horizontal: 10,vertical: 10)
    );

  }

  @override
  TreatmentSheetDetailViewModel createViewModel() {
    return TreatmentSheetDetailViewModel(context,id: widget.id);
  }

  @override
  Widget get separatorDivider => SizedBox(height: 12,);

  @override
  EdgeInsets get listPadding => EdgeInsets.symmetric(horizontal: 16,vertical: 12);
}